package cn.buk.tms.eotms.dto;

import cn.buk.tms.common.dto.base.BasePassengerDto;
import cn.buk.tms.eotms.entity.TicketOrder;
import cn.buk.tms.eotms.entity.TicketOrderPassenger;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 门票订单 Response DTO
 */
public class TicketOrderResponseDto {
  private int id;
  /**
   * 订单号
   */
  private String orderNo;
  /**
   * 景点ID
   */
  private int attractionId;
  /**
   * 景点名称
   */
  private String attractionName;
  /**
   * 游玩日期
   */
  private Date travelDate;
  /**
   * 门票单价
   */
  private double price;
  /**
   * 数量(和人数相等）
   */
  private int count;
  /**
   * 门票总价
   */
  private double total;
  /**
   * 备注
   */
  private String remark;
  private String operator;
  private int status;
  /**
   * 支付状态
   */
  private int payStatus;
  /**
   * 游客详情
   */
  private List<BasePassengerDto> passengers;

  public static TicketOrderResponseDto createdBy(TicketOrder info) {
    TicketOrderResponseDto dto = new TicketOrderResponseDto();

    BeanUtils.copyProperties(info, dto, "passengers");

    dto.setOrderNo(info.getOrderNo());
    dto.setAttractionId(info.getAttractionInfo().getId());
    dto.setAttractionName(info.getAttractionInfo().getName());

    for(TicketOrderPassenger psg: info.getPassengers()) {
      BasePassengerDto psgDto = new BasePassengerDto();
      BeanUtils.copyProperties(psg, psgDto);

      dto.getPassengers().add(psgDto);
    }

    return dto;
  }


  public int getAttractionId() {
    return attractionId;
  }

  public void setAttractionId(int attractionId) {
    this.attractionId = attractionId;
  }

  public Date getTravelDate() {
    return travelDate;
  }

  public void setTravelDate(Date travelDate) {
    this.travelDate = travelDate;
  }

  public double getPrice() {
    return price;
  }

  public void setPrice(double price) {
    this.price = price;
  }

  public double getTotal() {
    return total;
  }

  public void setTotal(double total) {
    this.total = total;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public List<BasePassengerDto> getPassengers() {
    if (passengers == null) {
      passengers = new ArrayList<>();
    }
    return passengers;
  }

  public void setPassengers(List<BasePassengerDto> passengers) {
    this.passengers = passengers;
  }

  public int getCount() {
    return count;
  }

  public void setCount(int count) {
    this.count = count;
  }

  public String getAttractionName() {
    return attractionName;
  }

  public void setAttractionName(String attractionName) {
    this.attractionName = attractionName;
  }

  public String getOrderNo() {
    return orderNo;
  }

  public void setOrderNo(String orderNo) {
    this.orderNo = orderNo;
  }

  public String getOperator() {
    return operator;
  }

  public void setOperator(String operator) {
    this.operator = operator;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getPayStatus() {
    return payStatus;
  }

  public void setPayStatus(int payStatus) {
    this.payStatus = payStatus;
  }
}
